import 'package:flutter/material.dart';
import 'package:flutter_screenutil/screenutil.dart';
/*
* 类似 预警提示纯文字提醒框 无输入文本框
*
*/
typedef onCloseEvent = void Function();
typedef onPositivePressEvent = void Function();
class PublicWarmToast extends Dialog {
  onCloseEvent closeCallBack;
  onPositivePressEvent positiveCallBack;
  String warmTip;
  String title;
  String agreetText;
  String cancelText;
  PublicWarmToast({
    this.agreetText,
    this.cancelText,
    this.title,
    this.warmTip,
    this.positiveCallBack,
    @required this.closeCallBack,
  });
 
  Widget MainComponent(){
    return Stack(
       children: [
         Opacity(
           opacity: 0.46,
           child:Container(
             color: Color(0xff101010),
             width: ScreenUtil.screenWidth,
             height: ScreenUtil.screenHeight,
           ) ,
         ),
         Positioned(
             top: ScreenUtil().setWidth(250),
             left: ScreenUtil().setWidth(503),
             child: CenterWidget()
         ),
       ],
    );
  }
  //中间视图背景
  Widget CenterBG(){
    return Container(
      decoration: ShapeDecoration(
        color: Color(0xffffffff),
        shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.all(
            Radius.circular(11.2),
          ),
        ),
      ),
      width:ScreenUtil().setWidth(624) ,
      height: ScreenUtil().setWidth(411.2),
    );
  }
  //中间视图
  Widget CenterWidget(){
    return Stack(
        children: <Widget>[
          CenterBG(),
          Positioned(
            left: ScreenUtil().setWidth(0),
            top: ScreenUtil().setWidth(0),
            child: Container(
              width: ScreenUtil().setWidth(624),
              height: ScreenUtil().setWidth(77.6),
              decoration: ShapeDecoration(
                color: Color(0xffF6F5F7),
                shape: RoundedRectangleBorder(
                  borderRadius: BorderRadius.only(
                      topLeft: Radius.circular(11.2),
                      topRight: Radius.circular(11.2),
                  ),
                ),
              ),
              child:Row(
                  children: [
                    SizedBox(width:ScreenUtil().setWidth(42.4),height: ScreenUtil().setWidth(20),),
                    Text(title, style: TextStyle(color: Color(0xff000000), fontFamily: 'PingFangSC-Medium',fontSize:ScreenUtil().setSp(26)),textAlign: TextAlign.center,),
                  ],
                ),
            ),
          ),
          Positioned(
            left: ScreenUtil().setWidth(16.8),
            top: ScreenUtil().setWidth(278.4),
            child: Container(
              width: ScreenUtil().setWidth(592),
              height: ScreenUtil().setWidth(2),
              color: Color(0xffE4E3E3),
            ),
          ),
          Positioned(
            child: Container(
              width: ScreenUtil().setWidth(624),
              height: ScreenUtil().setWidth(200.8),
              child:Column(
                children: [
                  SizedBox(width: 20,height: ScreenUtil().setWidth(81.4),),
                  Text(warmTip,style: TextStyle( color: Color(0xff454545),fontFamily: 'PingFangSC-Regular;',fontSize: ScreenUtil().setSp(26)),textAlign: TextAlign.center,maxLines: 3,overflow: TextOverflow.ellipsis,),
                ],
              ),
            ),
            top: ScreenUtil().setWidth(77.6),
            left: ScreenUtil().setWidth(0),
          ),
          Positioned(
            child: InkWell(
              onTap:(){
                this.closeCallBack();
              },
              child: Container(
                width: ScreenUtil().setWidth(191.6),
                height: ScreenUtil().setWidth(59.1),
                decoration: BoxDecoration(
                    borderRadius: BorderRadius.circular(30),
                    color:Color(0xffFFFFFF),
                    border: Border.all(
                        color: Color(0xffA2A1A3),
                        width: 1.5,
                        style: BorderStyle.solid
                    )
                ),
                child:new Center(
                  child: new Text(cancelText??"取消",style: TextStyle(fontSize: ScreenUtil().setSp(24),color: Color(0xff0A0A0B)),textAlign: TextAlign.center),
                ),
              ),
            ),
            left: ScreenUtil().setWidth(95),
            top: ScreenUtil().setWidth(310),
          ),
          Positioned(
            child: InkWell(
                onTap:(){
                  this.positiveCallBack();
                },
                child: Container(
                  width: ScreenUtil().setWidth(191.6),
                  height: ScreenUtil().setWidth(59.1),
                  decoration: BoxDecoration(
                      borderRadius: BorderRadius.circular(30),
                      color:Color(0xffF22A02),
                  ),
                  child: new Center(
                    child:new Text(agreetText??"确定",style: TextStyle(fontSize: ScreenUtil().setSp(24),color: Color(0xffFFFFFF)),textAlign: TextAlign.center,),
                   ),
                )
            ),
            left: ScreenUtil().setWidth(306),
            top: ScreenUtil().setWidth(310),
          ),
        ]
    );
  }
  @override
  Widget build(BuildContext context) {
    ScreenUtil.init(context, width: 1600, height: 900, allowFontScaling: true);
    return new Material(
        type: MaterialType.transparency,
        child: new Center(
          child: CenterWidget(),
        )
    );
  }
}



